
package modelLayer;

import java.util.ArrayList;
/**
 * Write a description of class DVD here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class DVD
{
    // instance variables - replace the example below with your own
    private String barcode;
    private String title;
    private String artist;
    private String publicationDate;
    private double price;
    private ArrayList<Copy> copyList;
    /**
     * Constructor for objects of class DVD
     */
    public DVD(String barcode, String title, String artist, String publicationDate, double price)
    {
        this.barcode = barcode;
        this.title = title;
        this.artist = artist;
        this.publicationDate = publicationDate;
        this.price = price;
        copyList = new ArrayList<Copy>();
    }
    
    // Get methods
    public String getBarcode()
    {
        return barcode;
    }
    public String getTitle()
    {
        return title;
    }
    public String getArtist()
    {
        return artist;
    }
    public String getPublicationDate()
    {
        return publicationDate;
    }
    public double getPrice()
    {
        return price;
    }
    
    
    // Set methods
    public void setBarcode(String newBarcode) 
    {
        barcode = newBarcode;
    }
    
    public void setTitle(String newTitle) 
    {
        title = newTitle;
    }
    
    public void setArtist(String newArtist) 
    {
        artist = newArtist;
    }
    
    public void setPublicationDate(String newPublicationDate) 
    {
        publicationDate = newPublicationDate;
    }
    
    public void setPrice(double newPrice) 
    {
        price = newPrice;
    }
    
    
    // Add a copy
    public void addCopy(Copy copy)
    {
        if(!copyList.contains(copy)) {
            copyList.add(copy);
        }
    }
    
    // Find a copy
    public Copy findCopy(String serialNumber)
    {
        Copy returnCopy = null;
        for(Copy copy : copyList)
        {
            if(copy.getSerialNumber().equals(serialNumber))
            {
                returnCopy = copy;
            }
            
        }
        return returnCopy;
    }
    
    // Update a copy
    public void updateCopy(Copy copy,String serialNumber, String purchaseDate) 
    {
        for(Copy copyItem : copyList) 
        {
            if(copyItem.equals(copy)) 
            {
                copyItem.setSerialNumber(serialNumber);
                copyItem.setPurchaseDate(purchaseDate);
            }
        }
    }
    
    // Delete a copy
    public void deleteCopy(Copy copy)
    {
        copyList.remove(copy);
    }
}

